﻿
#include <QtWidgets>
#include "frmmain.h"
#include "ui_frmmain.h"
#include "HCNetSDK.h"
#include "IPC_Dev.h"
#include "VideoItemTool.h"
#include <algorithm>

#pragma execution_character_set("utf-8")


static float radian(float x1, float y1, float x2, float y2){
	float radian_temp = 0.0f;
	float xx = 0.0f, yy = 0.0f;

	xx = x2 - x1;
	yy = y2 - y1;

	if (xx == 0.0)
		radian_temp = M_PI / 2.0;
	else
		radian_temp = atan(fabs(yy / xx));

	if ((xx < 0.0) && (yy >= 0.0))
		radian_temp = M_PI - radian_temp;
	else if ((xx < 0.0) && (yy < 0.0))
		radian_temp = M_PI + radian_temp;
	else if ((xx >= 0.0) && (yy < 0.0))
		radian_temp = M_PI * 2.0 - radian_temp;

	return (radian_temp);
}





class RS_NET_DVR_Login_Param {
public:
	frmMain* instance;
	IPC_Dev_Object_t device;
};


frmMain::frmMain(IPCManager* mgr , QWidget *parent) :
    QWidget(parent),
	ipc_mgr(mgr),
    ui(new Ui::frmMain),
	isLBPressed(false) ,
	LBPressdPoint(QPoint(0,0)),
	isRBPressed(false),
	RBPressedPoint(QPoint(0,0)){


    ui->setupUi(this);

	//ipc_mgr = new IPCManager();
	connect(ipc_mgr,SIGNAL(video_start_play(int)) ,this ,SLOT(onVideo_start_play(int)));
	connect(ipc_mgr, SIGNAL(video_stop_play(int)), this, SLOT(onVideo_stop_play(int)));
	//connect(ipc_mgr,SIGNAL(IPC_logionStatus(int,QString)),this,SLOT(onIPC_logionStatus(int,QString)));

    this->initForm();
    this->initMenu();
    this->show_video_all();
    QTimer::singleShot(300, this, SLOT(play_video_all()));

	setMouseTracking(true);


	//初始化使用的光标文件
	QSize cursorSize = QSize(32, 32);
	IPCMoveCursor[TILT_UP] = QCursor(QPixmap((":/RVMS/Resources/ctrl/TILT_UP.png")).scaled(cursorSize), -1, -1);
	IPCMoveCursor[TILT_DOWN] = QCursor(QPixmap((":/RVMS/Resources/ctrl/TILT_DOWN.png")).scaled(cursorSize), -1, -1);
	IPCMoveCursor[PAN_LEFT] = QCursor(QPixmap((":/RVMS/Resources/ctrl/PAN_LEFT.png")).scaled(cursorSize), -1, -1);
	IPCMoveCursor[PAN_RIGHT] = QCursor(QPixmap((":/RVMS/Resources/ctrl/PAN_RIGHT.png")).scaled(cursorSize), -1, -1);
	IPCMoveCursor[UP_LEFT] = QCursor(QPixmap((":/RVMS/Resources/ctrl/UP_LEFT.png")).scaled(cursorSize), -1, -1);
	IPCMoveCursor[UP_RIGHT] = QCursor(QPixmap((":/RVMS/Resources/ctrl/UP_RIGHT.png")).scaled(cursorSize), -1, -1);
	IPCMoveCursor[DOWN_LEFT] = QCursor(QPixmap((":/RVMS/Resources/ctrl/DOWN_LEFT.png")).scaled(cursorSize), -1, -1);
	IPCMoveCursor[DOWN_RIGHT] = QCursor(QPixmap((":/RVMS/Resources/ctrl/DOWN_RIGHT.png")).scaled(cursorSize), -1, -1);
}

frmMain::~frmMain()
{
    delete ui;
}



void frmMain::initForm()
{
    //设置样式表
    QStringList qss;
    qss.append("QFrame{border:2px solid #000000;}");
    qss.append("QLabel{font:75 25px;color:#F0F0F0;border:2px solid #AAAAAA;background:#000000;}");
    qss.append("QLabel:focus{border:2px solid #00BB9E;background:#555555;}");
	//qss.append("#FormVideoItem{border:2px solid #FFBB9E;background:#555555;}");
	
	//qss.append("QLabel:focus{border:2px solid #00BB9E;}");
    ui->frame->setStyleSheet(qss.join(""));

    videoMax = false;
    videoCount = MAX_VIDEO_COUNT;
    videoType = "1_9";

    for (int i = 0; i < videoCount; i++) {
      //  QLabel *widget = new QLabel;
		VideoPlayItemWidget* widget = new VideoPlayItemWidget(ipc_mgr , i , this);
		widget->setMouseTracking(true);
		/*
		注释:this->parent()->parent()为AppMainWindow窗体
		*/
		connect(widget, SIGNAL(captureSuccess(QString)),
			this->parent()->parent(), SLOT(onCaptureIMGSuccess(QString)));
		
		QLabel* label = widget->ui.label_Video;
		label->setMouseTracking(true);
        widget->setObjectName(QString("video%1").arg(i + 1));
		widget->setProperty("VideoIndex" , i);
        widget->installEventFilter(this);
		
        widget->setFocusPolicy(Qt::StrongFocus);
		label->setAlignment(Qt::AlignCenter);
		//label->setFocusPolicy(Qt::StrongFocus);
		//label->setStyleSheet(qss.join(""));
        //二选一可以选择显示文字,也可以选择显示背景图片
		label->setText(QString("通道 %1").arg(i + 1));
      //  widget->setPixmap(QPixmap(":/bg_novideo.png"));
        widgets.append(widget);
		widget_wids.push_back(label->winId());
    }
	ipc_mgr->set_play_widgets_wid(widget_wids);
}




void frmMain::initMenu()
{
    videoMenu = new QMenu(this);
    videoMenu->addAction("截图当前视频", this, SLOT(snapshot_video_one()));
    videoMenu->addAction("截图所有视频", this, SLOT(snapshot_video_all()));
    videoMenu->addSeparator();

    QMenu *menu4 = videoMenu->addMenu("切换到4画面");
	videoMenuActionMap["4-1-4"]  =  menu4->addAction("通道1-通道4", this, SLOT(show_video_4()));
	videoMenuActionMap["4-5-8"] = menu4->addAction("通道5-通道8", this, SLOT(show_video_4()));
	videoMenuActionMap["4-9-12"] = menu4->addAction("通道9-通道12", this, SLOT(show_video_4()));
	videoMenuActionMap["4-13-16"] = menu4->addAction("通道13-通道16", this, SLOT(show_video_4()));

    QMenu *menu6 = videoMenu->addMenu("切换到6画面");
	videoMenuActionMap["6-1-6"] = menu6->addAction("通道1-通道6", this, SLOT(show_video_6()));
	videoMenuActionMap["6-6-11"] = menu6->addAction("通道6-通道11", this, SLOT(show_video_6()));
	videoMenuActionMap["6-11-16"] = menu6->addAction("通道11-通道16", this, SLOT(show_video_6()));

    QMenu *menu8 = videoMenu->addMenu("切换到8画面");
	videoMenuActionMap["8-1-8"]= menu8->addAction("通道1-通道8", this, SLOT(show_video_8()));
	videoMenuActionMap["8-9-16"]= menu8->addAction("通道9-通道16", this, SLOT(show_video_8()));

    QMenu *menu9 = videoMenu->addMenu("切换到9画面");
	videoMenuActionMap["9-1-9"] = menu9->addAction("通道1-通道9", this, SLOT(show_video_9()));
	videoMenuActionMap["9-8-16"] = menu9->addAction("通道8-通道16", this, SLOT(show_video_9()));

	videoMenuActionMap["16-1-16"]=videoMenu->addAction("切换到16画面", this, SLOT(show_video_16()));

    videoMenuActionMap["36-1-36"] = videoMenu->addAction("切换到32画面", this, SLOT(show_video_36()));
}

void frmMain::show_video_all()
{
    if (videoType == "1_4") {
        change_video_4(0);
    } else if (videoType == "5_8") {
        change_video_4(4);
    } else if (videoType == "9_12") {
        change_video_4(8);
    } else if (videoType == "13_16") {
        change_video_4(12);
    } else if (videoType == "1_6") {
        change_video_6(0);
    } else if (videoType == "6_11") {
        change_video_6(5);
    } else if (videoType == "11_16") {
        change_video_6(10);
    } else if (videoType == "1_8") {
        change_video_8(0);
    } else if (videoType == "9_16") {
        change_video_8(8);
    } else if (videoType == "1_9") {
        change_video_9(0);
    } else if (videoType == "8_16") {
        change_video_9(7);
    } else if (videoType == "1_16") {
        change_video_16(0);
    }
    else if (videoType == "1_36") {
        change_video_36(0);
    }
}

void frmMain::show_video_4()
{
    videoMax = false;
    QString videoType;
    int index = 0;

    QAction *action = (QAction *)sender();
    QString name = action->text();

    if (name == "通道1-通道4") {
        index = 0;
        videoType = "1_4";
    } else if (name == "通道5-通道8") {
        index = 4;
        videoType = "5_8";
    } else if (name == "通道9-通道12") {
        index = 8;
        videoType = "9_12";
    } else if (name == "通道13-通道16") {
        index = 12;
        videoType = "13_16";
    }

    if (this->videoType != videoType) {
        this->videoType = videoType;
        change_video_4(index);
    }
}

void frmMain::show_video_6()
{
    videoMax = false;
    QString videoType;
    int index = 0;

    QAction *action = (QAction *)sender();
    QString name = action->text();

    if (name == "通道1-通道6") {
        index = 0;
        videoType = "1_6";
    } else if (name == "通道6-通道11") {
        index = 5;
        videoType = "6_11";
    } else if (name == "通道11-通道16") {
        index = 10;
        videoType = "11_16";
    }

    if (this->videoType != videoType) {
        this->videoType = videoType;
        change_video_6(index);
    }
}

void frmMain::show_video_8()
{
    videoMax = false;
    QString videoType;
    int index = 0;

    QAction *action = (QAction *)sender();
    QString name = action->text();

    if (name == "通道1-通道8") {
        index = 0;
        videoType = "1_8";
    } else if (name == "通道9-通道16") {
        index = 8;
        videoType = "9_16";
    }

    if (this->videoType != videoType) {
        this->videoType = videoType;
        change_video_8(index);
    }
}

void frmMain::show_video_9()
{
    videoMax = false;
    QString videoType;
    int index = 0;

    QAction *action = (QAction *)sender();
    QString name = action->text();

    if (name == "通道1-通道9") {
        index = 0;
        videoType = "1_9";
    } else if (name == "通道8-通道16") {
        index = 7;
        videoType = "8_16";
    }

    if (this->videoType != videoType) {
        this->videoType = videoType;
        change_video_9(index);
    }
}

void frmMain::show_video_16()
{
    videoMax = false;
    QString videoType;
    int index = 0;
    videoType = "1_16";

    if (this->videoType != videoType) {
        this->videoType = videoType;
        change_video_16(index);
    }
}

void frmMain::show_video_36()
{
    videoMax = false;
    QString videoType;
    int index = 0;
    videoType = "1_36";

    if (this->videoType != videoType) {
        this->videoType = videoType;
        change_video_36(index);
    }
}

void frmMain::hide_video_all()
{
    for (int i = 0; i < videoCount; i++) {
        ui->gridLayout->removeWidget(widgets.at(i));
        widgets.at(i)->setVisible(false);
    }
}

void frmMain::change_video(int index, int flag)
{
    int count = 0;
    int row = 0;
    int column = 0;

    for (int i = 0; i < videoCount; i++) {
        if (i >= index) {
            ui->gridLayout->addWidget(widgets.at(i), row, column);
            widgets.at(i)->setVisible(true);

            count++;
            column++;
            if (column == flag) {
                row++;
                column = 0;
            }
        }

        if (count == (flag * flag)) {
            break;
        }
    }
}

void frmMain::change_video_4(int index)
{
    hide_video_all();
    change_video(index, 2);
}

void frmMain::change_video_6(int index)
{
    hide_video_all();
    if (index == 0) {
        ui->gridLayout->addWidget(widgets.at(0), 0, 0, 2, 2);
        ui->gridLayout->addWidget(widgets.at(1), 0, 2, 1, 1);
        ui->gridLayout->addWidget(widgets.at(2), 1, 2, 1, 1);
        ui->gridLayout->addWidget(widgets.at(3), 2, 2, 1, 1);
        ui->gridLayout->addWidget(widgets.at(4), 2, 1, 1, 1);
        ui->gridLayout->addWidget(widgets.at(5), 2, 0, 1, 1);

        for (int i = 0; i < 6; i++) {
            widgets.at(i)->setVisible(true);
        }
    } else if (index == 5) {
        ui->gridLayout->addWidget(widgets.at(5), 0, 0, 2, 2);
        ui->gridLayout->addWidget(widgets.at(6), 0, 2, 1, 1);
        ui->gridLayout->addWidget(widgets.at(7), 1, 2, 1, 1);
        ui->gridLayout->addWidget(widgets.at(8), 2, 2, 1, 1);
        ui->gridLayout->addWidget(widgets.at(9), 2, 1, 1, 1);
        ui->gridLayout->addWidget(widgets.at(10), 2, 0, 1, 1);

        for (int i = 5; i < 11; i++) {
            widgets.at(i)->setVisible(true);
        }
    } else if (index == 10) {
        ui->gridLayout->addWidget(widgets.at(10), 0, 0, 2, 2);
        ui->gridLayout->addWidget(widgets.at(11), 0, 2, 1, 1);
        ui->gridLayout->addWidget(widgets.at(12), 1, 2, 1, 1);
        ui->gridLayout->addWidget(widgets.at(13), 2, 2, 1, 1);
        ui->gridLayout->addWidget(widgets.at(14), 2, 1, 1, 1);
        ui->gridLayout->addWidget(widgets.at(15), 2, 0, 1, 1);

        for (int i = 10; i < 16; i++) {
            widgets.at(i)->setVisible(true);
        }
    }
}

void frmMain::change_video_8(int index)
{
    hide_video_all();
    if (index == 0) {
        ui->gridLayout->addWidget(widgets.at(0), 0, 0, 3, 3);
        ui->gridLayout->addWidget(widgets.at(1), 0, 3, 1, 1);
        ui->gridLayout->addWidget(widgets.at(2), 1, 3, 1, 1);
        ui->gridLayout->addWidget(widgets.at(3), 2, 3, 1, 1);
        ui->gridLayout->addWidget(widgets.at(4), 3, 3, 1, 1);
        ui->gridLayout->addWidget(widgets.at(5), 3, 2, 1, 1);
        ui->gridLayout->addWidget(widgets.at(6), 3, 1, 1, 1);
        ui->gridLayout->addWidget(widgets.at(7), 3, 0, 1, 1);

        for (int i = 0; i < 8; i++) {
            widgets.at(i)->setVisible(true);
        }
    } else if (index == 8) {
        ui->gridLayout->addWidget(widgets.at(8), 0, 0, 3, 3);
        ui->gridLayout->addWidget(widgets.at(9), 0, 3, 1, 1);
        ui->gridLayout->addWidget(widgets.at(10), 1, 3, 1, 1);
        ui->gridLayout->addWidget(widgets.at(11), 2, 3, 1, 1);
        ui->gridLayout->addWidget(widgets.at(12), 3, 3, 1, 1);
        ui->gridLayout->addWidget(widgets.at(13), 3, 2, 1, 1);
        ui->gridLayout->addWidget(widgets.at(14), 3, 1, 1, 1);
        ui->gridLayout->addWidget(widgets.at(15), 3, 0, 1, 1);

        for (int i = 8; i < 16; i++) {
            widgets.at(i)->setVisible(true);
        }
    }
}

void frmMain::change_video_9(int index)
{
    hide_video_all();
    change_video(index, 3);
}

void frmMain::change_video_16(int index)
{
    hide_video_all();
    change_video(index, 4);
}

void frmMain::change_video_36(int index)
{
    hide_video_all();
    change_video(index, 6);
}

void frmMain::snapshot_video_one()
{

}

void frmMain::snapshot_video_all()
{

}

void frmMain::play_video_all()
{
	ipc_mgr->load_ipc_list();
	ipc_mgr->auto_play();
}


void frmMain::onVideo_start_play(int widget_index)
{
	qDebug() << "frmMain::on_video_start_play:" << widget_index;

	//widgets[widget_index]->ui.label_Video ->setUpdatesEnabled(false);
	update();
}
void frmMain::onVideo_stop_play(int widget_index)
{
	qDebug() << "frmMain::on_video_stop_play:" << widget_index;
	update(); 
	//widgets[widget_index]->setUpdatesEnabled(true);
}
void frmMain::onIPC_logionStatus(int status, QString uniqueKey)
{
	qDebug() << "=== onIPC_logionStatus:" << status << " / " << uniqueKey; 
}

bool frmMain::eventFilter(QObject *watched, QEvent *event)
{
	VideoPlayItemWidget *widget = qobject_cast<VideoPlayItemWidget*>(watched);
	if(widget == NULL)
		return QWidget::eventFilter(watched, event);

	 if (event->type() == QEvent::MouseMove) {
		QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
		onMouseMove_VIDEO(widget , mouseEvent);
	}
	else if (event->type() == QEvent::MouseButtonDblClick) {

		QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
		onMouseButtonDblClick_VIDEO(widget , mouseEvent);	
	}
	else if (event->type() == QEvent::MouseButtonPress) {

		QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
		onMouseButtonPress_VIDEO(widget, mouseEvent);
	
	}
	else if (event->type() == QEvent::MouseButtonRelease) {
	//鼠标按键释放
		QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
		onMouseButtonRelease_VIDEO(widget , mouseEvent);	
	}
	else if (event->type() == QEvent::Enter) {
	
	QString	Name = widget->objectName();
	widget->ToolBarEnable(true);
	//widget->update();
	}
	else if (event->type() == QEvent::Leave) {
		QString	Name = widget->objectName();
		widget->ToolBarEnable(false);
	//	widget->update();
	}
	else if (event->type() == QEvent::Resize) {
		QLabel* label = widget->ui.label_Video;
		QSize labelSize =  label->size();
		widget->setProperty("LabelSize", labelSize);
		int VideoIndex = widget->property("VideoIndex").toInt();
		ipc_mgr->SetWndSize(VideoIndex, labelSize);
	}
	else if (event->type() == QEvent::Wheel) {
		QWheelEvent *wheelEvent = static_cast<QWheelEvent *>(event);
		onWheel_VIDEO(widget , wheelEvent);
	}

	return QWidget:: eventFilter(watched, event);
}

void frmMain::onChangedViewGridMode(QString mode){
	QMap<QString, QAction*>::const_iterator i = videoMenuActionMap.find(mode);
	if (i != videoMenuActionMap.end()) {
		QAction* action = i.value();
		if(action)
			action->trigger();
	}	
}

void frmMain::onMouseButtonDblClick_VIDEO(VideoPlayItemWidget *widget, QMouseEvent *wheelEvent)
{
	if (!videoMax) {
		videoMax = true;
		hide_video_all();
		ui->gridLayout->addWidget(widget, 0, 0);
		widget->setVisible(true);
	}
	else {
		videoMax = false;
		show_video_all();
	}

}

void frmMain::onWheel_VIDEO(VideoPlayItemWidget *widget, QWheelEvent *wheelEvent)
{
	int delta = wheelEvent->delta(); 
	int factor = delta / 120;
	if (factor == 0)
		factor = 1;

	if (delta > 0) {
		//放大
		ipc_mgr->videoPTZCMDCurrent(ZOOM_IN, PTZ_MOVE_ACTION,7 );
		QCursor cursor;
		QPixmap pixmap(":/RVMS/Resources/ctrl/rescale.png");
		cursor = QCursor(pixmap, -1, -1);
		widget->setCursor(/*Qt::WaitCursor*/cursor);
		QTimer::singleShot(abs(factor)*500, [this, widget]() {
			widget->unsetCursor();
			ipc_mgr->videoPTZCMDCurrent(ZOOM_IN, PTZ_STOP_ACTION, 0);
		});
	}
	else {
		//缩小
		ipc_mgr->videoPTZCMDCurrent(ZOOM_OUT, PTZ_MOVE_ACTION, 7);
		QCursor cursor;
		QPixmap pixmap(":/RVMS/Resources/ctrl/zooming.png");
		cursor = QCursor(pixmap, -1, -1);
		widget->setCursor(cursor);
		//widget->setCursor(Qt::WaitCursor);
		QTimer::singleShot(abs(factor) * 500, [this, widget]() {
			if(widget)
				widget->unsetCursor();
			if(ipc_mgr)
				ipc_mgr->videoPTZCMDCurrent(ZOOM_OUT, PTZ_STOP_ACTION, 0);
		});
	}
}


void frmMain::onMouseMove_VIDEO(VideoPlayItemWidget *widget, QMouseEvent *mouseEvent)
{
	if (isLBPressed) {	
		int deltaX = mouseEvent->x() - LBPressdPoint.x();
		int deltaY = mouseEvent->y() - LBPressdPoint.y();
		double dist =sqrt( static_cast<double>( deltaX*deltaX + deltaY*deltaY ) );

		int WidgetR = std::min(widget->width() , widget->height())/2.0;
		double Speed = (double)dist / (double)WidgetR *10;

		printf("WidgetR=%d,dist=%.1f\r\n" , WidgetR , dist);
		if (Speed > 7)
			Speed = 7;
		if (Speed < 1)
			Speed = 1;

		qDebug() << "MOVE:" << widget->property("VideoIndex") << " " << Speed;

		float rad = radian(0, 0, deltaX, deltaY);
		float angle = rad * 180 / M_PI;
		DWORD CMD = ipc_mgr->videoPTZMoveCurrent(angle ,PTZ_MOVE_ACTION , Speed);
		if (CMD == -1)
			return;

		auto it = IPCMoveCursor.find(CMD);
		if (it == IPCMoveCursor.end())
			return;

		widget->setCursor(it.value());
	}

	if (isRBPressed) {
		IPC3DLocationPaintParam_t locP;
		locP.isDraw = true;
		locP.EndPoint = mouseEvent->pos();
		ipc_mgr->Set3DDrawParam(locP , SET_3DLOC_ENABLE| SET_3DLOC_END);
	}
}

void frmMain::onMouseButtonPress_VIDEO(VideoPlayItemWidget *widget, QMouseEvent *mouseEvent) {
	QString	Name = widget->objectName();
	int VideoIndex = widget->property("VideoIndex").toInt();
	ipc_mgr->SetCurrentSelVideoIndex(VideoIndex); //保存当前选择的Video索引

	if (mouseEvent->button() == Qt::RightButton) {
		//右键按下
		//videoMenu->exec(QCursor::pos());

		isRBPressed = true;
		RBPressedPoint = mouseEvent->pos();

		qDebug() << "RBPressedPoint::" << RBPressedPoint;

		IPC3DLocationPaintParam_t locP;
		locP.isDraw = true;
		locP.StartPoint = locP.EndPoint = RBPressedPoint;
		ipc_mgr->Set3DDrawParam(locP);

		//RBPressedPoint = widget->ui.label_Video->mapFrom(widget, mouseEvent->pos()); // widget->mapTo(widget->ui.label_Video, mouseEvent->pos());
	}
	else {
		//左键按下
		isLBPressed = true;
		LBPressdPoint = mouseEvent->pos();
	}
}
void frmMain::onMouseButtonRelease_VIDEO(VideoPlayItemWidget *widget, QMouseEvent *mouseEvent)
{

	if (isRBPressed) {
		//正在进行3D定位
		QPoint curPos = mouseEvent->pos();	
	//	QPoint pos = widget->ui.label_Video->mapFrom(widget , mouseEvent->pos()); // widget->mapTo(widget->ui.label_Video, mouseEvent->pos()); /* mouseEvent->pos();*/
		NET_DVR_POINT_FRAME PointFrame;
		memset(&PointFrame,0 ,sizeof(NET_DVR_POINT_FRAME));

		int width = widget->width();
		int height = widget->height();
		qDebug() << "onMouseButtonRelease_VIDEO::" << curPos << "width:" << width <<"height:"<< height;
		PointFrame.xTop =(RBPressedPoint.x() * 255/ width);
		PointFrame.yTop = (RBPressedPoint.y() * 255 / height);

		PointFrame.xBottom = (curPos.x() * 255 / width);
		PointFrame.yBottom = (curPos.y() * 255 / height);
		ipc_mgr->IPC3DLocationCurrent(PointFrame, widget->geometry(), RBPressedPoint, curPos);

		IPC3DLocationPaintParam_t locP;
		locP.isDraw = false;
		ipc_mgr->Set3DDrawParam(locP);
	}

	if (isLBPressed) {
		ipc_mgr->videoPTZMoveCurrent(0, PTZ_STOP_ACTION);//停止镜头的移动
	}
	isRBPressed = false;
	isLBPressed = false;
	widget->unsetCursor(); //恢复光标形状
	
}


